package com.css.fxfzfxqh.modules.reportmanagement.service.impl;

import com.css.fxfzfxqh.modules.reportmanagement.reportutil.DzzhDzryqkCustomTableMethodPolicy2;
import com.css.fxfzfxqh.modules.reportmanagement.service.ExportReportDataService;
import com.css.fxfzfxqh.modules.reportmanagement.service.PgbgZdryqkReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class PgbgDzryqkReportServiceImpl implements PgbgZdryqkReportService {
    private static final Logger logger = LoggerFactory.getLogger(PgbgDzryqkReportServiceImpl.class);
    @Resource
    private JdbcTemplate jdbcTemplate;

    @Resource
    private ExportReportDataService exportReportDataService;

    DzzhDzryqkCustomTableMethodPolicy2 tableMethodPolicy = new DzzhDzryqkCustomTableMethodPolicy2();

    /**
     * 3 地震灾害风险确定评估
     *3.3.2 人员死亡评估结果
     * @param taskId
     * @return
     */
    public List<Map<String,Object>> getFxqhCasualtiesCalculationEdForDeathDataList(String taskId,String inputMode){
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT                                                                                             ");
        sb.append("	province_name,                                                                                   ");
        sb.append("	city_name,                                                                                       ");
        sb.append("	county_name,                                                                                     ");
        sb.append("cast(rate_6 as DEC(10,2)) rate_6,                                    ");
        sb.append("cast(rate_7 as DEC(10,2)) rate_7,                                    ");
        sb.append("cast(rate_8 as DEC(10,2)) rate_8,                                    ");
        sb.append("cast(rate_9 as DEC(10,2)) rate_9,                                    ");
        sb.append("cast(rate_10 as DEC(10,2)) rate_10,                                  ");
        sb.append("	type_name,                                                                                       ");
        sb.append("	order_num                                                                                        ");
        sb.append("FROM                                                                                               ");
        sb.append("	(                                                                                                ");
        sb.append("	SELECT                                                                                           ");
        sb.append("		province_name,                                                                           ");
        sb.append("		city_name,                                                                               ");
        sb.append("		county_name,                                                                             ");
        sb.append("		rate_6,                                                                                  ");
        sb.append("		rate_7,                                                                                  ");
        sb.append("		rate_8,                                                                                  ");
        sb.append("		rate_9,                                                                                  ");
        sb.append("		rate_10,                                                                                 ");
        sb.append("		'白天' AS type_name,                                                                     ");
        sb.append("		1 AS order_num                                                                           ");
        sb.append("	FROM                                                                                          ");
        sb.append("		(                                                                                        ");
        sb.append("		SELECT                                                                                   ");
        sb.append("			province_name,                                                                   ");
        sb.append("			city_name,                                                                       ");
        sb.append("			county_name,                                                                     ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅵ' THEN day_death ELSE 0 END ) AS rate_6,          ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅶ' THEN day_death ELSE 0 END ) AS rate_7,          ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅷ' THEN day_death ELSE 0 END ) AS rate_8,          ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅸ' THEN day_death ELSE 0 END ) AS rate_9,          ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅹ' THEN day_death ELSE 0 END ) AS rate_10          ");
        sb.append("		FROM                                                                                     ");
        sb.append("			fxqh_casualties_calculation_ed T                                                 ");
        sb.append("		WHERE                                                                                    ");
        sb.append("			assess_id = ?     and flag=?                                ");
        sb.append("		GROUP BY                                                                                 ");
        sb.append("			province_name,                                                                   ");
        sb.append("			city_name,                                                                       ");
        sb.append("			county_name                                                                      ");
        sb.append("		) t1 UNION ALL                                                                           ");
        sb.append("	SELECT                                                                                           ");
        sb.append("		province_name,                                                                           ");
        sb.append("		city_name,                                                                               ");
        sb.append("		county_name,                                                                             ");
        sb.append("		rate_6,                                                                                  ");
        sb.append("		rate_7,                                                                                  ");
        sb.append("		rate_8,                                                                                  ");
        sb.append("		rate_9,                                                                                  ");
        sb.append("		rate_10,                                                                                 ");
        sb.append("		'夜间' AS type_name,                                                                     ");
        sb.append("		2 AS order_num                                                                           ");
        sb.append("	FROM                                                                                          ");
        sb.append("		(                                                                                        ");
        sb.append("		SELECT                                                                                   ");
        sb.append("			province_name,                                                                   ");
        sb.append("			city_name,                                                                       ");
        sb.append("			county_name,                                                                     ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅵ' THEN night_death ELSE 0 END ) AS rate_6,        ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅶ' THEN night_death ELSE 0 END ) AS rate_7,        ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅷ' THEN night_death ELSE 0 END ) AS rate_8,        ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅸ' THEN night_death ELSE 0 END ) AS rate_9,        ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅹ' THEN night_death ELSE 0 END ) AS rate_10        ");
        sb.append("		FROM                                                                                  ");
        sb.append("			fxqh_casualties_calculation_ed T                                                 ");
        sb.append("		WHERE                                                                                  ");
        sb.append("			assess_id = ?      and flag=?                               ");
        sb.append("		GROUP BY                                                                               ");
        sb.append("			province_name,                                                                   ");
        sb.append("			city_name,                                                                       ");
        sb.append("			county_name                                                                      ");
        sb.append("		) t2                                                                                     ");
        sb.append("	) T                                                                                              ");
        sb.append("ORDER BY                                                                                                 ");
        sb.append("	order_num                                                                                        ");
        String sql = sb.toString();
        logger.info("getFxqhCasualtiesCalculationEdForDeathDataList方法查询的SQL:{},参数:{}",sb.toString(),taskId,taskId);
        List<Map<String,Object>> dataList = jdbcTemplate.queryForList(sql,taskId,inputMode,taskId,inputMode);
        return dataList;
    }

    /**
     * 3 地震灾害风险确定评估
     * 3.2.2 人员受伤评估结果
     * @param taskId
     * @return
     */
    @Override
    public List<Map<String,Object>> getFxqhCasualtiesCalculationEdForInjureDataList(String taskId,String inputMode){
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT                                                                                                   ");
        sb.append("	province_name,                                                                                   ");
        sb.append("	city_name,                                                                                       ");
        sb.append("	county_name,                                                                                     ");
        sb.append("cast(rate_6 as DEC(10,2)) rate_6,                                    ");
        sb.append("cast(rate_7 as DEC(10,2)) rate_7,                                    ");
        sb.append("cast(rate_8 as DEC(10,2)) rate_8,                                    ");
        sb.append("cast(rate_9 as DEC(10,2)) rate_9,                                    ");
        sb.append("cast(rate_10 as DEC(10,2)) rate_10,                                  ");
        sb.append("	type_name,                                                                                       ");
        sb.append("	order_num                                                                                        ");
        sb.append("FROM                                                                                                     ");
        sb.append("	(                                                                                                ");
        sb.append("	SELECT                                                                                           ");
        sb.append("		province_name,                                                                           ");
        sb.append("		city_name,                                                                               ");
        sb.append("		county_name,                                                                             ");
        sb.append("		rate_6,                                                                                  ");
        sb.append("		rate_7,                                                                                  ");
        sb.append("		rate_8,                                                                                  ");
        sb.append("		rate_9,                                                                                  ");
        sb.append("		rate_10,                                                                                 ");
        sb.append("		'白天' AS type_name,                                                                     ");
        sb.append("		1 AS order_num                                                                           ");
        sb.append("	FROM                                                                                             ");
        sb.append("		(                                                                                        ");
        sb.append("		SELECT                                                                                   ");
        sb.append("			province_name,                                                                   ");
        sb.append("			city_name,                                                                       ");
        sb.append("			county_name,                                                                     ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅵ' THEN day_injure ELSE 0 END ) AS rate_6,         ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅶ' THEN day_injure ELSE 0 END ) AS rate_7,         ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅷ' THEN day_injure ELSE 0 END ) AS rate_8,         ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅸ' THEN day_injure ELSE 0 END ) AS rate_9,         ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅹ' THEN day_injure ELSE 0 END ) AS rate_10         ");
        sb.append("		FROM                                                                                     ");
        sb.append("			fxqh_casualties_calculation_ed T                                                 ");
        sb.append("		WHERE                                                                                    ");
        sb.append("			assess_id =?   and flag=?                               ");
        sb.append("		GROUP BY                                                                                 ");
        sb.append("			province_name,                                                                   ");
        sb.append("			city_name,                                                                       ");
        sb.append("			county_name                                                                      ");
        sb.append("		) t1 UNION ALL                                                                           ");
        sb.append("	SELECT                                                                                           ");
        sb.append("		province_name,                                                                           ");
        sb.append("		city_name,                                                                               ");
        sb.append("		county_name,                                                                             ");
        sb.append("		rate_6,                                                                                  ");
        sb.append("		rate_7,                                                                                  ");
        sb.append("		rate_8,                                                                                  ");
        sb.append("		rate_9,                                                                                  ");
        sb.append("		rate_10,                                                                                 ");
        sb.append("		'夜间' AS type_name,                                                                     ");
        sb.append("		2 AS order_num                                                                           ");
        sb.append("	FROM                                                                                             ");
        sb.append("		(                                                                                        ");
        sb.append("		SELECT                                                                                   ");
        sb.append("			province_name,                                                                   ");
        sb.append("			city_name,                                                                       ");
        sb.append("			county_name,                                                                     ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅵ' THEN night_injure ELSE 0 END ) AS rate_6,       ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅶ' THEN night_injure ELSE 0 END ) AS rate_7,       ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅷ' THEN night_injure ELSE 0 END ) AS rate_8,       ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅸ' THEN night_injure ELSE 0 END ) AS rate_9,       ");
        sb.append("			SUM ( CASE WHEN intensity = 'Ⅹ' THEN night_injure ELSE 0 END ) AS rate_10       ");
        sb.append("		FROM                                                                                     ");
        sb.append("			fxqh_casualties_calculation_ed T                                                 ");
        sb.append("		WHERE                                                                                    ");
        sb.append("			assess_id = ?  and flag=?                                 ");
        sb.append("		GROUP BY                                                                                 ");
        sb.append("			province_name,                                                                   ");
        sb.append("			city_name,                                                                       ");
        sb.append("			county_name                                                                      ");
        sb.append("		) t2                                                                                     ");
        sb.append("	) T                                                                                              ");
        sb.append("ORDER BY                                                                                                 ");
        sb.append("	order_num                                                                                        ");
        String sql = sb.toString();
        logger.info("getFxqhCasualtiesCalculationEdForinjureDataList方法查询的SQL:{},参数:{}",sb.toString(),taskId,taskId);
        List<Map<String,Object>> dataList = jdbcTemplate.queryForList(sql,taskId,inputMode,taskId,inputMode);
        return dataList;
    }

    @Override
    public List<Map<String, Object>> getFxqhCasualtiesCalculationEdForDeathDataList_Report2(String taskId,String inputMode) {
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT                                                                                                        ");
        sb.append("	province_name,                                                                                        ");
        sb.append("	city_name,                                                                                            ");
        sb.append("	county_name,                                                                                          ");
        sb.append("	cast(rate_6 as DEC(10,2)) rate_6,                                                                     ");
        sb.append("	cast(rate_7 as DEC(10,2)) rate_7,                                                                     ");
        sb.append("	cast(rate_8 as DEC(10,2)) rate_8,                                                                     ");
        sb.append("	cast(rate_10 as DEC(10,2)) rate_10,                                                                   ");
        sb.append("	type_name,                                                                                            ");
        sb.append("	order_num                                                                                             ");
        sb.append("FROM                                                                                                          ");
        sb.append("	(                                                                                                     ");
        sb.append("	SELECT                                                                                                ");
        sb.append("		province_name,                                                                                ");
        sb.append("		city_name,                                                                                    ");
        sb.append("		county_name,                                                                                  ");
        sb.append("		rate_6,                                                                                       ");
        sb.append("		rate_7,                                                                                       ");
        sb.append("		rate_8,                                                                                       ");
        sb.append("		rate_10,                                                                                      ");
        sb.append("		'白天' AS type_name,                                                                          ");
        sb.append("		1 AS order_num                                                                                ");
        sb.append("	FROM                                                                                                  ");
        sb.append("		(                                                                                             ");
        sb.append("		SELECT                                                                                        ");
        sb.append("			province_name,                                                                        ");
        sb.append("			city_name,                                                                            ");
        sb.append("			county_name,                                                                          ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz1' THEN day_death ELSE 0 END ) AS rate_6,          ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz2' THEN day_death ELSE 0 END ) AS rate_7,          ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz3' THEN day_death ELSE 0 END ) AS rate_8,          ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz4' THEN day_death ELSE 0 END ) AS rate_10          ");
        sb.append("		FROM                                                                                          ");
        sb.append("			fxqh_casualties_calculation_ed T                                                      ");
        sb.append("		WHERE                                                                                         ");
        sb.append("			assess_id = ?    and flag=?                                       ");
        sb.append("		GROUP BY                                                                                      ");
        sb.append("			province_name,                                                                        ");
        sb.append("			city_name,                                                                            ");
        sb.append("			county_name                                                                           ");
        sb.append("		) t1 UNION ALL                                                                                ");
        sb.append("	SELECT                                                                                                ");
        sb.append("		province_name,                                                                                ");
        sb.append("		city_name,                                                                                    ");
        sb.append("		county_name,                                                                                  ");
        sb.append("		rate_6,                                                                                       ");
        sb.append("		rate_7,                                                                                       ");
        sb.append("		rate_8,                                                                                       ");
        sb.append("		rate_10,                                                                                      ");
        sb.append("		'夜间' AS type_name,                                                                          ");
        sb.append("		2 AS order_num                                                                                ");
        sb.append("	FROM                                                                                                  ");
        sb.append("		(                                                                                             ");
        sb.append("		SELECT                                                                                        ");
        sb.append("			province_name,                                                                        ");
        sb.append("			city_name,                                                                            ");
        sb.append("			county_name,                                                                          ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz1'  THEN night_death ELSE 0 END ) AS rate_6,       ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz2' THEN night_death ELSE 0 END ) AS rate_7,        ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz3' THEN night_death ELSE 0 END ) AS rate_8,        ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz4' THEN night_death ELSE 0 END ) AS rate_10        ");
        sb.append("		FROM                                                                                          ");
        sb.append("			fxqh_casualties_calculation_ed T                                                      ");
        sb.append("		WHERE                                                                                         ");
        sb.append("			assess_id = ?   and flag=?                                        ");
        sb.append("		GROUP BY                                                                                      ");
        sb.append("			province_name,                                                                        ");
        sb.append("			city_name,                                                                            ");
        sb.append("			county_name                                                                           ");
        sb.append("		) t2                                                                                          ");
        sb.append("	) T                                                                                                   ");
        sb.append("ORDER BY                                                                                                      ");
        sb.append("	order_num                                                                                             ");
        String sql = sb.toString();
        logger.info("getFxqhCasualtiesCalculationEdForDeathDataList_Report2方法查询的SQL:{},参数:{},{}",sb.toString(),taskId,taskId);
        List<Map<String,Object>> dataList = jdbcTemplate.queryForList(sql,taskId,inputMode,taskId,inputMode);
        return dataList;
    }

    @Override
    public List<Map<String, Object>> getFxqhCasualtiesCalculationEdForInjureDataList_Report2(String taskId,String inputMode) {
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT                                                                                                             ");
        sb.append("	province_name,                                                                                             ");
        sb.append("	city_name,                                                                                                 ");
        sb.append("	county_name,                                                                                               ");
        sb.append("	cast(rate_6 as DEC(10,2)) rate_6,                                                                     ");
        sb.append("	cast(rate_7 as DEC(10,2)) rate_7,                                                                     ");
        sb.append("	cast(rate_8 as DEC(10,2)) rate_8,                                                                     ");
        sb.append("	cast(rate_10 as DEC(10,2)) rate_10,                                                                   ");
        sb.append("	type_name,                                                                                                 ");
        sb.append("	order_num                                                                                                  ");
        sb.append("FROM                                                                                                               ");
        sb.append("	(                                                                                                          ");
        sb.append("	SELECT                                                                                                     ");
        sb.append("		province_name,                                                                                     ");
        sb.append("		city_name,                                                                                         ");
        sb.append("		county_name,                                                                                       ");
        sb.append("		rate_6,                                                                                            ");
        sb.append("		rate_7,                                                                                            ");
        sb.append("		rate_8,                                                                                            ");
        sb.append("		rate_10,                                                                                           ");
        sb.append("		'白天' AS type_name,                                                                               ");
        sb.append("		1 AS order_num                                                                                     ");
        sb.append("	FROM                                                                                                       ");
        sb.append("		(                                                                                                  ");
        sb.append("		SELECT                                                                                             ");
        sb.append("			province_name,                                                                             ");
        sb.append("			city_name,                                                                                 ");
        sb.append("			county_name,                                                                               ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz1' THEN day_injure ELSE 0 END ) AS rate_6,              ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz2' THEN day_injure ELSE 0 END ) AS rate_7,              ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz3' THEN day_injure ELSE 0 END ) AS rate_8,              ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz4' THEN day_injure ELSE 0 END ) AS rate_10              ");
        sb.append("		FROM                                                                                               ");
        sb.append("			fxqh_casualties_calculation_ed T                                                           ");
        sb.append("		WHERE                                                                                              ");
        sb.append("			assess_id = ?   and flag=?                                              ");
        sb.append("		GROUP BY                                                                                           ");
        sb.append("			province_name,                                                                             ");
        sb.append("			city_name,                                                                                 ");
        sb.append("			county_name                                                                                ");
        sb.append("		) t1 UNION ALL                                                                                     ");
        sb.append("	SELECT                                                                                                     ");
        sb.append("		province_name,                                                                                     ");
        sb.append("		city_name,                                                                                         ");
        sb.append("		county_name,                                                                                       ");
        sb.append("		rate_6,                                                                                            ");
        sb.append("		rate_7,                                                                                            ");
        sb.append("		rate_8,                                                                                            ");
        sb.append("		rate_10,                                                                                           ");
        sb.append("		'夜间' AS type_name,                                                                               ");
        sb.append("		2 AS order_num                                                                                     ");
        sb.append("	FROM                                                                                                       ");
        sb.append("		(                                                                                                  ");
        sb.append("		SELECT                                                                                             ");
        sb.append("			province_name,                                                                             ");
        sb.append("			city_name,                                                                                 ");
        sb.append("			county_name,                                                                               ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz1' THEN night_injure ELSE 0 END ) AS rate_6,            ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz2' THEN night_injure ELSE 0 END ) AS rate_7,            ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz3' THEN night_injure ELSE 0 END ) AS rate_8,            ");
        sb.append("			SUM ( CASE WHEN condition = 'sgglsz4' THEN night_injure ELSE 0 END ) AS rate_10            ");
        sb.append("		FROM                                                                                               ");
        sb.append("			fxqh_casualties_calculation_ed T                                                           ");
        sb.append("		WHERE                                                                                              ");
        sb.append("			assess_id = ?  and flag=?                                               ");
        sb.append("		GROUP BY                                                                                           ");
        sb.append("			province_name,                                                                             ");
        sb.append("			city_name,                                                                                 ");
        sb.append("			county_name                                                                                ");
        sb.append("		) t2                                                                                               ");
        sb.append("	) T                                                                                                        ");
        sb.append("ORDER BY                                                                                                           ");
        sb.append("	order_num                                                                                                  ");

        String sql = sb.toString();
        logger.info("getFxqhCasualtiesCalculationEdForInjureDataList_Report2方法查询的SQL:{},参数:{},{}",sb.toString(),taskId,taskId);
        List<Map<String,Object>> dataList = jdbcTemplate.queryForList(sql,taskId,inputMode,taskId,inputMode);
        return dataList;
    }


    @Override
    public List<Map<String, Object>> getFxqhCasualtiesCalculationPdForInjureDataList_Report4(String taskId,String[] yearSplit) {
//        return getFxqhCasualtiesCalculationPd(taskId,"1");
        return getFxqhCasualtiesCalculationPdPlus(taskId,"rysw1",yearSplit);
    }

    @Override
    public List<Map<String, Object>> getFxqhCasualtiesCalculationPdForDeathDataList_Report4(String taskId,String[] yearSplit) {
//        return getFxqhCasualtiesCalculationPd(taskId,"2");
        return getFxqhCasualtiesCalculationPdPlus(taskId,"rysw2",yearSplit);
    }


    /**
     *
     * @param taskId 任务ID
     * @param type  --人员伤亡(死亡2重伤1)
     * @return
     */
    private List<Map<String, Object>> getFxqhCasualtiesCalculationPd(String taskId,String type){
        StringBuilder sb = new StringBuilder();
        sb.append("select province_name,                                                                                                     ");
        sb.append("city_name,                                                                                                                ");
        sb.append("county_name,                                                                                                              ");
        sb.append("type_name,                                                                                                                ");
        sb.append("cast(rate_6 as dec(10,2)) as rate_6,                                                                                      ");
        sb.append("cast(rate_7 as dec(10,2)) as rate_7,                                                                                      ");
        sb.append("cast(rate_8 as dec(10,2)) as rate_8,                                                                                      ");
        sb.append("cast(rate_9 as dec(10,2)) as rate_9,                                                                                      ");
        sb.append("cast(rate_10  as dec(10,2)) as rate_10                                                                                    ");
        sb.append("from (                                                                                                                    ");
        sb.append("SELECT                                                                                                                    ");
        sb.append("			province_name,                                                                                    ");
        sb.append("			city_name,                                                                                        ");
        sb.append("			county_name,                                                                                      ");
        sb.append("			CASE WHEN time = '1' THEN '白天'  when time='0' then '夜间' end as type_name,                     ");
        sb.append("			SUM ( CASE WHEN years = '1'  THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_6,    ");
        sb.append("			SUM ( CASE WHEN years = '10' THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_7,    ");
        sb.append("			SUM ( CASE WHEN years = '20' THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_8,    ");
        sb.append("			SUM ( CASE WHEN years = '30' THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_9,    ");
        sb.append("			SUM ( CASE WHEN years = '50' THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_10    ");
        sb.append("		FROM                                                                                                      ");
        sb.append("			fxqh_casualties_calculation_pd T                                                                  ");
        sb.append("		WHERE                                                                                                     ");
        sb.append("			assess_id = ?                                                    ");
        sb.append("			and casualties=?                                                    ");
        sb.append("		GROUP BY                                                                                                  ");
        sb.append("			province_name,                                                                                    ");
        sb.append("			city_name,                                                                                        ");
        sb.append("			county_name,                                                                                      ");
        sb.append("		time	                                                                                                  ");
        sb.append("		) t                                                                                                       ");
        String sql = sb.toString();
        logger.info("getFxqhCasualtiesCalculationPd方法查询的SQL:{},参数:{}",sb.toString(),taskId,type);
        List<Map<String,Object>> dataList = jdbcTemplate.queryForList(sql,taskId,type);
        return dataList;

    }
    @Override
    public List<Map<String, Object>> getFxqhCasualtiesCalculationPdPlus(String taskId,String type,String[] yearSplit){
        StringBuilder sb = new StringBuilder();
        sb.append("select province_name,                                                                                                     ");
        sb.append("city_name,                                                                                                                ");
        sb.append("county_name,                                                                                                              ");
        sb.append("type_name                                                                                                                ");
        for (int numSheet = 0; numSheet < yearSplit.length; numSheet++) {
            sb.append(" , cast(rate_"+(6+numSheet)+" as dec(10,2)) as rate_"+(6+numSheet)+" ");
        }
//        sb.append("cast(rate_6 as dec(10,2)) as rate_6,                                                                                      ");
//        sb.append("cast(rate_7 as dec(10,2)) as rate_7,                                                                                      ");
//        sb.append("cast(rate_8 as dec(10,2)) as rate_8,                                                                                      ");
//        sb.append("cast(rate_9 as dec(10,2)) as rate_9,                                                                                      ");
//        sb.append("cast(rate_10  as dec(10,2)) as rate_10                                                                                    ");

        sb.append(" from (                                                                                                                    ");
        sb.append("SELECT                                                                                                                    ");
        sb.append("			province_name,                                                                                    ");
        sb.append("			city_name,                                                                                        ");
        sb.append("			CASE WHEN time = 'sjd1' THEN '白天'  when time='sjd2' then '夜间' end as type_name,                     ");
        for (int numSheet = 0; numSheet < yearSplit.length; numSheet++) {
            sb.append(" SUM ( CASE WHEN years ='"+yearSplit[numSheet]+"'  THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_"+(6+numSheet)+",");
        }
//        sb.append("			SUM ( CASE WHEN years = '1'  THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_6,    ");
//        sb.append("			SUM ( CASE WHEN years = '10' THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_7,    ");
//        sb.append("			SUM ( CASE WHEN years = '20' THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_8,    ");
//        sb.append("			SUM ( CASE WHEN years = '30' THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_9,    ");
//        sb.append("			SUM ( CASE WHEN years = '50' THEN cast (calculated_value as DEC(16,6)) ELSE 0 END ) AS rate_10    ");
        sb.append("			county_name                                                                                          ");
        sb.append("		FROM                                                                                                      ");
        sb.append("			fxqh_casualties_calculation_pd T                                                                  ");
        sb.append("		WHERE                                                                                                     ");
        sb.append("			assess_id = ?                                                    ");
        sb.append("			and casualties=?                                                    ");
        sb.append("		GROUP BY                                                                                                  ");
        sb.append("			province_name,                                                                                    ");
        sb.append("			city_name,                                                                                        ");
        sb.append("			county_name,                                                                                      ");
        sb.append("		time	                                                                                                  ");
        sb.append("		) t                                                                                                       ");
        String sql = sb.toString();
        logger.info("getFxqhCasualtiesCalculationPd方法查询的SQL:{},参数:{}",sb.toString(),taskId,type);
        List<Map<String,Object>> dataList = jdbcTemplate.queryForList(sql,taskId,type);
        return dataList;

    }
}
